package algos;

import java.text.DecimalFormat;


public class ProbaObject {
    private Object obj;
    private Float prob;
    private Float nbObj;

    public ProbaObject(Object obj, Float prob) {
        this.obj = obj;
        this.prob = prob;
        this.nbObj = 1.0f;
    }
    
    public void incremementNbObj(){
        nbObj++;
    }
    
    public void calcProb(Float nbTotal){
        this.prob = (nbObj/nbTotal);
    }
   
    @Override
    public boolean equals(Object arg0) {         
        return this.obj.equals(((ProbaObject)arg0).obj);
    }
    
    @Override
    public String toString() {
        String masque = new String("###.##");
        DecimalFormat form = new DecimalFormat(masque);
        return obj.toString() + "\nProbabilite = " + form.format(prob * 100.0f) + "%\n";
    }

    public Float getNbObj() {
        return nbObj;
    }

    public Object getObj() {
        return obj;
    }

    public Float getProb() {
        return prob;
    }

    
    
    
}
